home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / TURB_VIS / TVDMX / DMXFORMS.PAS < prev    next >
Pascal/Delphi Source File  |  1994-06-20  |  17KB  |  644 lines

  1.  
  2. {■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■}
  3. {                            }
  4. {    DMXFORMS  --Form Editing Unit            }
  5. {    tvDMX      --data editing project (ver 2.x)    }
  6. {                            }
  7. {    Copyright (c) 1994  Randolph Beck        }
  8. {                P.O. Box  56-0487        }
  9. {                Orlando, FL 32856        }
  10. {                CIS:  72361,753        }
  11. {                            }
  12. {■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■}
  13.  
  14. Unit DMXFORMS;
  15.  
  16. {$B-,D+,O+,R-,V-,X+ }
  17.  
  18. interface
  19.  
  20. uses Objects, Drivers, Memory, Views, Dialogs, Menus, App,
  21.      RSet, DmxGizma, tvDMX;
  22.  
  23. const
  24.     { additional buttons and options for EntryBox }
  25.     mfHelpButton    = $0001;
  26.     mfViewOnly        = $0002;
  27.     mfDefault        = $0004;
  28.  
  29.     { EntryBox defaults }
  30.     hcEntryBox        : word      = 0;
  31.   {$IFDEF VER60 }
  32.     dpEntryBox        : integer = 1;
  33.   {$ELSE }
  34.     dpEntryBox        : integer = dpGrayDialog;
  35.   {$ENDIF }
  36.  
  37.     FormButtons: array[0..4] of string[8] =
  38.        ('~Y~es',
  39.     '~N~o',
  40.     'O~K~',
  41.     'Cancel',
  42.     '~H~elp');
  43.  
  44.     CDmxDlgForm        = #26#12#10#10#01#02;
  45.     CDmxDlgFormOff    = #01#12#10#10#01#02;
  46.              {  |  |  |  |    |  |  }
  47.   {  1 normal fields -------+  |  |  |    |  |  }
  48.   {  2 normal selected field --+  |  |    |  |  }
  49.   {  3 read-only selected field --+  |    |  |  }
  50.   {  4 locked field -----------------+    |  |  }
  51.   {  5 delimiter -----------------------+  |  }
  52.   {  6 border -----------------------------+  }
  53.  
  54. type
  55.     PFldPtrArray    = ^TFldPtrArray;
  56.     TFldPtrArray    =  array[0..8195] of pDMXfieldrec;
  57.  
  58.  
  59.     PDmxForm        = ^TDmxForm;
  60.     TDmxForm        =  OBJECT(TDmxEditor)
  61.     InScrl        : boolean;
  62.     NumRows        : integer;
  63.     DMXfields    : PFldPtrArray;
  64.       constructor Init(ATemplates : PSItem;  AInScroll : boolean;
  65.             var AData;  var Bounds : TRect;  ALabels,ARecInd : PDmxLink;
  66.             AHScrollBar,AVScrollBar : PScrollBar);
  67.       function    DataAt(RecNum : integer) : pointer;  VIRTUAL;
  68.       procedure DoneStruct;   VIRTUAL;
  69.       procedure Draw;          VIRTUAL;
  70.       procedure HandleEvent(var Event : TEvent);  VIRTUAL;
  71.       procedure InitStruct(var ATemplate );  VIRTUAL;
  72.       procedure LoadStruct(var S : TStream);  VIRTUAL;
  73.       procedure SetupField;   VIRTUAL;
  74.       procedure SetupRecord;  VIRTUAL;
  75.       procedure StoreStruct(var S : TStream);  VIRTUAL;
  76.       private
  77.     FirstDataRow    : integer;
  78.     PrevRec        : integer;
  79.     end;
  80.  
  81.  
  82.     PDmxDlgForm        = ^TDmxDlgForm;
  83.     TDmxDlgForm        =  OBJECT(TDmxForm)
  84.       constructor Init(ATemplates : PSItem;
  85.             var Bounds : TRect;
  86.             AHScrollBar,AVScrollBar : PScrollBar);
  87.       function    DataSize : word;  VIRTUAL;
  88.       procedure DoneData;  VIRTUAL;
  89.       procedure GetData(var Rec );    VIRTUAL;
  90.       function    GetPalette : PPalette;    VIRTUAL;
  91.       procedure InitData(var AData );    VIRTUAL;
  92.       procedure SetData(var Rec );    VIRTUAL;
  93.       function  Valid(Command: word) : boolean;  VIRTUAL;
  94.     end;
  95.  
  96.  
  97.   procedure MakeEntryBox(ADialog: PDialog; DMX: PDmxDlgForm;
  98.              AOptions: word; AForm: PSItem);
  99.  
  100.   function  EntryBox(Title: string; AData: pointer; AOptions: word; AForm: PSItem) : word;
  101.  
  102.   procedure RegisterDMXFORMS;
  103.  
  104.  
  105. const
  106.     RDmxForm    :  TStreamRec =(
  107.     ObjType:  rnDmxForm;
  108.     VmtLink:  ofs(TypeOf(TDmxForm)^);
  109.     Load:      @TDmxForm.Load;
  110.     Store:      @TDmxForm.Store
  111.       );
  112.  
  113.     RDmxDlgForm    :  TStreamRec =(
  114.     ObjType:  rnDmxDlgForm;
  115.     VmtLink:  ofs(TypeOf(TDmxDlgForm)^);
  116.     Load:      @TDmxDlgForm.Load;
  117.     Store:      @TDmxDlgForm.Store
  118.       );
  119.  
  120.  
  121. implementation
  122.  
  123.   { ══════════════════════════════════════════════════════════════════════ }
  124.  
  125.  
  126. procedure MakeEntryBox(ADialog: PDialog; DMX: PDmxDlgForm;
  127.             AOptions: word;  AForm: PSItem);
  128. const
  129.     BtnWidth = 10;
  130.     Commands: array[0..4] of word = (cmYes, cmNo, cmOK, cmCancel, cmHelp);
  131. var
  132.     i,W,X,Y,BtnCount    : integer;
  133.     BtnList        : array[0..5] of PButton;
  134.     S            : string;
  135.     R            : TRect;
  136.     Line        : PSItem;
  137.     b,XBar,YBar        : boolean;
  138.     LMargin        : integer;
  139.  
  140.     function  HScrollBar : PScrollBar;
  141.     begin
  142.       If XBar then
  143.     HScrollBar := ADialog^.StandardScrollBar(sbHorizontal + sbHandleKeyboard)
  144.        else
  145.     HScrollBar := nil;
  146.     end;
  147.  
  148.     function  VScrollBar : PScrollBar;
  149.     var  R:   TRect;
  150.      Bar: PScrollBar;
  151.     begin
  152.       If YBar then
  153.     begin
  154.     Bar := ADialog^.StandardScrollBar(sbVertical + sbHandleKeyboard);
  155.     If (BtnCount > 0) then
  156.       begin
  157.       Bar^.GetBounds(R);
  158.       Dec(R.B.Y, 4);
  159.       Bar^.Locate(R);
  160.       end;
  161.     VScrollBar := Bar;
  162.     end
  163.        else
  164.     VScrollBar := nil;
  165.     end;
  166.  
  167.     procedure AssignBtn(BtnNum: integer);
  168.     var bf: byte;
  169.     begin
  170.       BtnList[BtnCount] := New(PButton, Init(R, FormButtons[BtnNum], Commands[BtnNum], bfNormal));
  171.       If (AOptions and mfDefault <> 0) and (Commands[BtnNum] = cmOK) then
  172.     BtnList[BtnCount]^.AmDefault := TRUE;
  173.       Inc(X, BtnWidth + 2);
  174.       Inc(BtnCount);
  175.     end;
  176.  
  177. begin
  178.   If (ADialog = nil) or (AForm = nil) then Exit;
  179.   X := -2;
  180.   BtnCount := 0;
  181.   R.Assign(0, 0, BtnWidth, 2);
  182.   For i := 0 to 3 do If (AOptions and ($0100 shl i) <> 0) then AssignBtn(i);
  183.   If (AOptions and mfHelpButton <> 0) then AssignBtn(4);
  184.   W := BtnCount * (BtnWidth + 2) + 2;
  185.   If (W+2 < MinWinSize.X) then W := MinWinSize.X - 2;
  186.   Y := 0;
  187.   Line := AForm;
  188.   b := FALSE;
  189.   While (Line <> nil) do
  190.     begin
  191.     If (Line^.Value <> nil) then
  192.       begin
  193.       i := DmxStrLen(Line^.Value^);
  194.       If (W < i) then
  195.         begin
  196.         W := i;
  197.         b := TRUE;
  198.         end;
  199.       end;
  200.     Inc(Y);
  201.     Line := Line^.Next;
  202.     end;
  203.   If b then LMargin := 1 else
  204.     begin
  205.     LMargin := succ(W - MaxItemStrLen(AForm)) div 2;
  206.     If (LMargin < 1) then LMargin := 1;
  207.     end;
  208.   R.Assign(0,0, W+2, Y+2);
  209.   If (BtnCount > 0) then Inc(Y, 2);
  210.   If (BtnCount > 0) then Inc(R.B.Y, 4);
  211.   XBar := (R.B.X > DeskTop^.Size.X);
  212.   If XBar then R.B.X := DeskTop^.Size.X;
  213.   YBar := (R.B.Y > DeskTop^.Size.Y);
  214.   If YBar then R.B.Y := DeskTop^.Size.Y;
  215.   ADialog^.Locate(R);
  216.   With ADialog^ do
  217.     begin
  218.     Options := Options or ofCentered;
  219.     Palette := dpEntryBox;
  220.     HelpCtx := hcEntryBox;
  221.     R.Grow(-1,-1);
  222.     If (BtnCount > 0) then Dec(R.B.Y, 4);
  223.     R.A.X := LMargin;
  224.  
  225.     {New(DMX, Init(AForm, R, HScrollBar,VScrollBar));}
  226.     DMX^.HScrollBar := HScrollBar;
  227.     DMX^.VScrollBar := VScrollBar;
  228.     Move(AForm, S[1], sizeof(PSItem));
  229.     S[0] := #4;
  230.     DMX^.InitStruct(S);
  231.     If not LowMemory and (DMX^.RecordSize > 0) then
  232.       begin
  233.       GetMem(DMX^.WorkingData, DMX^.RecordSize);
  234.       FillChar(DMX^.WorkingData^, DMX^.RecordSize, 0);
  235.       end;
  236.     DMX^.SetLimit(DMX^.Limit.X, DMX^.NumRows);
  237.     DMX^.Locate(R);
  238.  
  239.     DisposeSItems(AForm);
  240.     If YBar then DMX^.Options := DMX^.Options or ofFramed;
  241.     If (AOptions and mfViewOnly <> 0) or (DMX^.DataBlockSize <= 0) then
  242.       begin
  243.       DMX^.Locked := TRUE;
  244.       If (DMX^.HScrollBar = nil) and (DMX^.VScrollBar = nil) then
  245.     DMX^.Options := DMX^.Options and not ofSelectable;
  246.       end;
  247.     Insert(DMX);
  248.     X := (Size.X - X) shr 1;
  249.     For i := 0 to pred(BtnCount) do
  250.       begin
  251.       Insert(BtnList[i]);
  252.       BtnList[i]^.MoveTo(X, Size.Y - 3);
  253.       Inc(X, BtnList[i]^.Size.X + 2);
  254.       end;
  255.     SelectNext(FALSE);
  256.     end;
  257. end;
  258.  
  259.  
  260. function  EntryBox(Title: string; AData: pointer; AOptions: word; AForm: PSItem) : word;
  261. var  Dialog  : PDialog;
  262.      R         : TRect;
  263.      Command : word;
  264. begin
  265.   R.Assign(0,0,0,0);
  266.   Dialog := New(PDialog, Init(R, Title));
  267.   MakeEntryBox(Dialog, New(PDmxDlgForm, Init(nil,R,nil,nil)), AOptions, AForm);
  268.   If (Application^.ValidView(Dialog) = nil) then
  269.     EntryBox := cmCancel
  270.    else
  271.     begin
  272.   {$IFDEF VER60 }
  273.     If (AData <> nil) then Dialog^.SetData(AData^);
  274.     Command := DeskTop^.ExecView(Dialog);
  275.     If (Command <> cmCancel) and (AData <> nil) then Dialog^.GetData(AData^);
  276.     Dispose(Dialog, Done);
  277.     EntryBox := Command;
  278.   {$ELSE }
  279.     EntryBox := Application^.ExecuteDialog(Dialog, AData);
  280.   {$ENDIF }
  281.     end;
  282. end;
  283.  
  284.  
  285.   { ══ TDmxForm ══════════════════════════════════════════════════════════ }
  286.  
  287.  
  288. constructor TDmxForm.Init(ATemplates : PSItem;    AInScroll : boolean;
  289.             var AData;  var Bounds : TRect;  ALabels,ARecInd : PDmxLink;
  290.             AHScrollBar,AVScrollBar : PScrollBar);
  291. var  S : string[sizeof(PSItem) + 1];
  292. begin
  293.   Move(ATemplates, S[1], sizeof(PSItem));
  294.   S[0] := #4;
  295.   TDmxEditor.Init(S, AData, 0, Bounds, ALabels, ARecInd, AHScrollBar, AVScrollBar);
  296.   InScrl := AInScroll;
  297. end;
  298.  
  299.  
  300. procedure TDmxForm.LoadStruct(var S : TStream);
  301. var  i : integer;
  302. begin
  303.   S.Read(InScrl,  sizeof(InScrl));
  304.   S.Read(NumRows, sizeof(NumRows));
  305.   S.Read(FirstDataRow, sizeof(FirstDataRow));
  306.   If (NumRows > 0) then
  307.     begin
  308.     GetMem(DMXfields,(NumRows * 4) + 200);
  309.     For i := 0 to pred(NumRows) do
  310.       begin
  311.       TDmxEditor.LoadStruct(S);
  312.       DMXfields^[i] := DMXfield1;
  313.       end;
  314.     end;
  315.   PrevRec := -1;
  316. end;
  317.  
  318.  
  319. function  TDmxForm.DataAt(RecNum : integer) : pointer;
  320. begin
  321.   DMXfield1 := DMXfields^[RecNum];
  322.   DataAt := WorkingData;
  323. end;
  324.  
  325.  
  326. procedure TDmxForm.DoneStruct;
  327. var  Items,P : PSItem;
  328.      i,Lim   : integer;
  329. begin
  330.   If (DMXfields = nil) then Exit;
  331.   i := NumRows;
  332.   While (i > 0) do
  333.     begin
  334.     DMXfield1 := DMXfields^[pred(i)];
  335.     If (DMXfield1 <> nil) then TDmxEditor.DoneStruct;
  336.     Dec(i);
  337.     end;
  338.   FreeMem(DMXfields,(NumRows * 4) + 200);
  339.   NumRows := 0;
  340.   Limit.X := 0;
  341.   DataBlockSize := 0;
  342.   RecordSize := 0;
  343. end;
  344.  
  345.  
  346. procedure TDmxForm.Draw;
  347. begin
  348.   TDmxScroller.Draw;
  349.   DMXfield1 := DMXfields^[CurrentRecord];
  350.   If FieldSelected and (showanyway in ShowFmt) and (CurrentField <> nil) then
  351.     DrawField(CurrentField);
  352. end;
  353.  
  354.  
  355. procedure TDmxForm.HandleEvent(var Event : TEvent);
  356. var  i,j    : word;
  357.      RS,FS    : boolean;
  358.      MousePlace    : TPoint;
  359.      PrevFld    : pDMXfieldrec;
  360.      E        : TEvent;
  361.      CurRec,Direction,WasY    : integer;
  362. begin
  363.   CurRec  := CurrentRecord;
  364.   Direction := 0;
  365.   PrevFld := CurrentField;
  366.   WasY      := Delta.Y;
  367.   With Event do
  368.     If (Event.What = evMouseDown) and GetState(sfFocused) and
  369.        (MouseInView(Where)) then
  370.       begin
  371.       RS := RecordSelected;
  372.       FS := FieldSelected;
  373.       If FS then EvaluateField;
  374.       If RS then EvaluateRecord;
  375.       MakeLocal(Where, MousePlace);
  376.       MousePlace.X := MousePlace.X + Delta.X;
  377.       MousePlace.Y := MousePlace.Y + Delta.Y;
  378.       i := cmDMX_goto;
  379.       DMXfield1 := DMXfields^[MousePlace.Y];
  380.       PrevFld    := CurrentField;
  381.       CurrentField := DMXfield1;
  382.       If (MousePlace.Y < Limit.Y) then
  383.     ProcessCommand(i, MousePlace)
  384.        else
  385.     DoubleValid := FALSE;
  386.       If DoubleValid then
  387.     begin
  388.     If Double then
  389.       begin
  390.       With E do
  391.         begin
  392.         What := evCommand;
  393.         Command := cmDMX_DoubleClick;
  394.         InfoPtr := @Self;
  395.         end;
  396.       PutEvent(E);
  397.       end;
  398.     end
  399.        else
  400.     begin
  401.     {WrongKeypressed(Event);}
  402.     CurrentField := PrevFld;
  403.     end;
  404.       ClearEvent(Event);
  405.       If RS then SetupRecord;
  406.       If FS then SetupField;
  407.       If DoubleValid and (CurrentField <> nil) and
  408.      (upcase(CurrentField^.typecode) = fldCLUSTER)
  409.        then
  410.     Message(@Self, evKeyDown, $2020, @Self);
  411.       end
  412.      else
  413.       begin
  414.       Case What of
  415.     evCommand,evBroadcast:
  416.       begin
  417.       Case Command of
  418.         cmDMX_Up,    cmDMX_PgUp:    Direction := -2;
  419.         cmDMX_Down, cmDMX_PgDn:    Direction :=  2;
  420.         cmDMX_Enter:        Direction :=  1;
  421.         cmDMX_Draw, cmDMX_DrawData:
  422.         begin
  423.         DrawView;
  424.         If (What = evCommand) then ClearEvent(Event);
  425.         end;
  426.         end;
  427.       end;
  428.     end;
  429.       TDmxEditor.HandleEvent(Event);
  430.       If (Direction <> 0) and (CurrentRecord = CurRec) and
  431.      (State and sfSelected <> 0) and (Owner <> nil) and
  432.      (Delta.Y = WasY) and
  433.      ((abs(Direction) > 1) or (CurrentField = PrevFld))
  434.        then
  435.     begin
  436.     If (Direction = 1) then Message(Owner, evBroadcast, cmDefault, @Self);
  437.     Owner^.SelectNext(Direction < 0);
  438.     end;
  439.       end;
  440. end;
  441.  
  442.  
  443. procedure TDmxForm.InitStruct(var ATemplate );
  444. var  Items    : PSItem;
  445.      i,Lim    : integer;
  446.      AllZ    : boolean;
  447.      S        : string;
  448. begin
  449.   Move(string(ATemplate)[1], Items, sizeof(Items));
  450.   If (Items = nil) then Exit;
  451.   FirstDataRow := -1;
  452.   AllZ := (Items^.Value <> nil) and (Items^.Value^[1] = ^A);
  453.   Repeat
  454.     Inc(NumRows);
  455.     Items := Items^.Next;
  456.   Until (Items = nil);
  457.   Move(string(ATemplate)[1], Items, sizeof(Items));
  458.   GetMem(DMXfields,(NumRows * 4) + 200);
  459.   i := 0;
  460.   Lim := 0;
  461.   While (Items <> nil) and (not LowMemory) do
  462.     begin
  463.     Limit.X := 0;
  464.     DMXfield1 := nil;
  465.     If (Items^.Value = nil) or (Items^.Value^ = '') or (Items^.Value^ = ^A) then
  466.       S := ' '
  467.      else
  468.       S := Items^.Value^;
  469.     If AllZ and (length(S) < pred(sizeof(S))) then Insert(^A, S, 1);
  470.     TDmxEditor.InitStruct(S);
  471.     If (FirstDataRow < 0) and (RecordSize > 0) then
  472.       begin
  473.       CurrentField := DMXfield1;
  474.       While (CurrentField <> nil) and ((CurrentField^.fieldsize = 0)
  475.      or (CurrentField^.access and (accHidden or accSkip) <> 0)) do
  476.     CurrentField := CurrentField^.Next;
  477.       If (CurrentField <> nil) then FirstDataRow := i;
  478.       end;
  479.     If (Lim < Limit.X) then Lim := Limit.X;
  480.     DMXfields^[i] := DMXfield1;
  481.     Inc(i);
  482.     Items := Items^.Next;
  483.     end;
  484.   Limit.X := Lim;
  485.   DataBlockSize := RecordSize;
  486.   DataBlockSize := DataBlockSize * NumRows;
  487.   If (FirstDataRow >= 0) then CurrentRecord := FirstDataRow;
  488.   DMXfield1 := DMXfields^[CurrentRecord];
  489.   PrevRec := -1;
  490. end;
  491.  
  492.  
  493. procedure TDmxForm.SetUpField;
  494. begin
  495.   TDmxEditor.SetUpField;
  496.   If InScrl and (CurrentField <> nil) and
  497.      (upcase(CurrentField^.typecode) in[fldSTR, fldSTRNUM, fldCHAR, fldCHARNUM])
  498.    then
  499.     FirstKey := FALSE;
  500. end;
  501.  
  502.  
  503. procedure TDmxForm.SetupRecord;
  504. var  i,n : integer;
  505.      cmd : word;
  506.      cf,was : pDMXfieldrec;
  507. begin
  508.   was := CurrentField;
  509.   If (CurrentField = nil) then n := 0 else n := CurrentField^.screentab;
  510.   DMXfield1 := DMXfields^[CurrentRecord];
  511.   CurrentField := DMXfield1;
  512.   If (DMXfield1 <> nil) then
  513.     begin
  514.     While (CurrentField <> nil) and ((CurrentField^.fieldsize = 0) or
  515.       (CurrentField^.access and (accHidden or accSkip) <> 0)) do
  516.       CurrentField := CurrentField^.Next;
  517.     If (CurrentField = nil) then
  518.       begin
  519.       If (CurrentRecord = 0) then PrevRec := -1;
  520.       If (CurrentRecord = pred(Limit.Y)) then PrevRec := Limit.Y;
  521.       If (PrevRec > CurrentRecord) then cmd := cmDMX_Up else cmd := cmDMX_Down;
  522.       CurrentField := was;
  523.       Message(@Self, evCommand, cmd, @Self);
  524.       TDmxForm.SetupRecord;
  525.       Exit;
  526.       end
  527.      else
  528.       begin
  529.       cf := CurrentField;
  530.       While (cf <> nil) and (cf^.screentab <= n) do
  531.     begin
  532.     If (cf^.fieldsize > 0) and (cf^.access and (accHidden or accSkip) = 0)
  533.      then CurrentField := cf;
  534.     cf := cf^.Next;
  535.     end;
  536.       n := Delta.X;
  537.       If (n + CurrentField^.screentab + CurrentField^.shownwid > Size.X) then
  538.     n := CurrentField^.screentab + CurrentField^.shownwid - Size.X;
  539.       If (n > CurrentField^.screentab) then n := CurrentField^.screentab;
  540.       If (n <> Delta.X) then ScrollTo(n, Delta.Y);
  541.       end;
  542.     end;
  543.   TDmxEditor.SetupRecord;
  544.   PrevRec := CurrentRecord;
  545. end;
  546.  
  547.  
  548. procedure TDmxForm.StoreStruct(var S : TStream);
  549. var  i : integer;
  550. begin
  551.   S.Write(InScrl,  sizeof(InScrl));
  552.   S.Write(NumRows, sizeof(NumRows));
  553.   S.Write(FirstDataRow, sizeof(FirstDataRow));
  554.   If (NumRows > 0) then
  555.     For i := 0 to pred(NumRows) do
  556.       begin
  557.       DMXfield1 := DMXfields^[i];
  558.       TDmxEditor.StoreStruct(S);
  559.       end;
  560.   PrevRec := -1;
  561. end;
  562.  
  563.  
  564.   { ══ TDmxDlgForm ═══════════════════════════════════════════════════════ }
  565.  
  566.  
  567. constructor TDmxDlgForm.Init(ATemplates : PSItem;
  568.             var Bounds : TRect;
  569.             AHScrollBar,AVScrollBar : PScrollBar);
  570. begin
  571.   TDmxForm.Init(ATemplates, TRUE, Mem[0:0], Bounds, nil,nil, AHScrollBar, AVScrollBar);
  572.   Options := Options or ofFirstClick;
  573. end;
  574.  
  575.  
  576. function  TDmxDlgForm.DataSize : word;
  577. begin
  578.   DataSize := RecordSize;
  579. end;
  580.  
  581.  
  582. procedure TDmxDlgForm.DoneData;
  583. begin
  584.   If (WorkingData <> nil) and (RecordSize > 0) then
  585.     FreeMem(WorkingData, RecordSize);
  586. end;
  587.  
  588.  
  589. procedure TDmxDlgForm.GetData(var Rec );
  590. begin
  591.   Move(WorkingData^, Rec, DataSize);
  592. end;
  593.  
  594.  
  595. function  TDmxDlgForm.GetPalette : PPalette;
  596. const  P1 : string[length(CDmxDlgForm)] = CDmxDlgForm;
  597.        P2 : string[length(CDmxDlgForm)] = CDmxDlgFormOff;
  598. begin
  599.   If (Options and ofSelectable <> 0) then
  600.     GetPalette := @P1
  601.    else
  602.     GetPalette := @P2;
  603. end;
  604.  
  605.  
  606. procedure TDmxDlgForm.InitData(var AData );
  607. begin
  608.   If not LowMemory and (RecordSize > 0) then
  609.     begin
  610.     GetMem(WorkingData, RecordSize);
  611.     FillChar(WorkingData^, RecordSize, 0);
  612.     end;
  613. end;
  614.  
  615.  
  616. procedure TDmxDlgForm.SetData(var Rec );
  617. begin
  618.   Move(Rec, WorkingData^, DataSize);
  619. end;
  620.  
  621.  
  622. function  TDmxDlgForm.Valid(Command: word) : boolean;
  623. var  V    : boolean;
  624. begin
  625.   Valid := inherited Valid(Command) and
  626.       ((Command <> cmValid) or (WorkingData <> nil));
  627. end;
  628.  
  629.  
  630.   { ══════════════════════════════════════════════════════════════════════ }
  631.  
  632.  
  633. procedure RegisterDMXFORMS;
  634. begin
  635.   RegisterType(RDmxForm);
  636.   RegisterType(RDmxDlgForm);
  637. end;
  638.  
  639.  
  640.   { ══════════════════════════════════════════════════════════════════════ }
  641.  
  642.  
  643. End.
  644.